from django.utils.deprecation import MiddlewareMixin
import jwt
from mydjango.settings import SECRET_KEY

class MyToken(MiddlewareMixin):
    def process_request(self,request):
        token = request.GET.get('token')
        if token:
            try:
                uid = jwt.decode(token,SECRET_KEY,algorithms='HS256')['uid']
                request.uid = uid
            except Exception as e:
                print(e)